//
//  ImageViewController.m
//  礼物
//
//  Created by dllo on 15/11/10.
//  Copyright © 2015年 liangsicheng. All rights reserved.
//

#import "ImageViewController.h"

@interface ImageViewController ()

@end

@implementation ImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"列表";
    self.imageCycleView=[[ImageCycleView alloc]initWithFrame:MAINSCREEN];
    [self.view addSubview:self.imageCycleView];
    self.imageCycleView.delegate=self;
     self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"iconfont-fanhui.png"] style:UIBarButtonItemStyleDone target:self action:@selector(leftBarButtonItemAction:)];
    NSString *str=[NSString stringWithFormat:@"http://api.liwushuo.com/v2/collections/%ld/posts?gender=1&generation=20&limit=20&offset=0",self.model.target_id];
    [AppToolss getAFNetWorkingData:str andBlock:^(id data) {
        self.imageCycleView.imageCycleCellArray=[NSMutableArray array];
        NSMutableDictionary *Dic=data;
        NSMutableArray *array=[[Dic objectForKey:@"data"]objectForKey:@"posts"];
        for (NSMutableDictionary *dic in array) {
            Model *model=[[Model alloc]init];
            [model setValuesForKeysWithDictionary:dic];
            [self.imageCycleView.imageCycleCellArray addObject:model];
        }
        [self.imageCycleView.myTableView reloadData];
        
    } andError:^(id failure) {}];
    
}
-(void)leftBarButtonItemAction:(UIBarButtonItem *)barButtonItem
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)imageCyclePushDetailControllerProtocol:(Model *)model;
{
    GiftDetailViewController *detailVC=[[GiftDetailViewController alloc]init];
    detailVC.model=model;
    detailVC.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:detailVC animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
